<!--#include file="Config.asp"-->
<!--#include file="emp_is.asp"-->
<!--#include file="Header.asp"-->
<%
If request("fatherID")<>"" then
fatherID=int(request("fatherID"))
Else
fatherID=1
End if
%>

<table class="table">
<form method="post" action="?Action=Add">
<tr>
<th>
<select name="fatherID">
<option value="0">0.顶级分类</option>
<%
sql="select * from CMDB_Type where type_fatherID=0 order by type_ID"
Rs.open sql,conn,1,1
for m=1 to rs.recordcount
%>
<option value=<%=Rs("type_ID")%>><%=rs("type_ID")%>.<%=rs("type_name")%></option>
<%
rs.moveNext
Next
rs.close
%>
</select>
Name<input type="text" name="name" >
URL<input type="text" name="url"  value="" size='40'>
Target
<select name="URLTarget">
<option value="FrmMain">FrmMain</option>
<option value="_blank">_blank</option>
<option value="_self">_self</option>
<option value="FrmLeftMenu">FrmLeftMenu</option>
</select>

<input type="text" name="Comment" value="说明">
<select name="isshow">
<option value="1" selected>显示</option>
<option value="0">不显示</option>
</select>
排序<input type="text" name="paixu" value="1" size='3'>
<input type="submit" name="Submit" value="添加">
</th>
</tr>
</form>
</table>


<table class="table table-condensed">
<tr>
<TH width='180' valign='top'>
<!-- ---------------------------- -->
<table class="table">
<tr>
<TD>
<a href="?fatherID=0"><b>0.全部分类</b></a><br>
</TD>
</TR>
<%
sql="select * from CMDB_Type where type_fatherID=0 order by type_ID"
Rs.open sql,conn,1,1
for m=1 to rs.recordcount
%>
<tr>
<TD>
<a href="?fatherID=<%=int(Rs("Type_ID"))%>"><b><%=int(Rs("Type_ID"))%>.<%=Trim(rs("Type_name"))%></b></a><br>
</TD>
</TR>
<%
rs.moveNext
Next
rs.close
%>
</table>
<!-- ---------------------------- -->
</th>
<td valign='top'>
<!-- MenuMainList -->

<table class="table">
<tr>
<TH >ID</TH>
<TH >Edit</TH>
<TH >Name</TH>
<TH>说明</TH>
<TH>物资政策</TH>
</TR>
<%

If fatherID=0 then
sql="select * from CMDB_Type where type_fatherID="&fatherID&" order by type_ID"
else
sql="select * from CMDB_Type where type_ID="&fatherID&" order by type_ID"
End If

rs.open sql,conn,1,1
r_f_count=rs.recordcount
for r_f=1 To r_f_count
%>
<tr bgcolor='#ffcc00'>
<TD  ><%=rs("type_id")%></TD>
<TD ><A HREF="CMDB_Edit.asp?EditID=<%=Trim(rs("type_id"))%>" target='_blank'>修改</A></TD>
<td ><B><%=Trim(rs("type_name"))%></B></TD>
<TD ><%=rs("type_Comment")%></TD>
<TD ><%=rs("type_Policy")%></TD>
</tr>
<%
sqls="select * from CMDB_Type where type_FatherID='"&Trim(rs("type_id"))&"' order by type_ID"
rss.open sqls,conn,1,1
If rss.recordcount>=1 Then
for r_s=1 to rss.recordcount
%>
<tr >
<TD ><%=Trim(rss("type_id"))%></TD>
<TD ><A HREF="CMDB_Edit.asp?ID=<%=Trim(rss("type_id"))%>" target='_blank' title='<%=Trim(rss("type_name"))%>'>修改</A></TD>
<td  ><B><%=Trim(rss("type_name"))%></B></TD>
<TD ><%=rss("type_Comment")%></TD>
<TD ><%=rss("type_Policy")%></TD>
</tr>


<%
rss.moveNext
Next
End if
rss.close
%>

<%
rs.MoveNext
Next

rs.close
%>
</TABLE>

</td>
</tr>
</TABLE>

<%
'SQL Precess
Action=request("Action")
'Add New Record
If Action="Add" then
sql= "SELECT * from CMDB_Type WHERE (type_id is null)"
rs.open sql,conn,1,3
rs.addnew
rs("type_name") =Trim(Request("name"))
rs("type_fatherID") =CInt(Request("fatherID"))
rs("type_comment") =Trim(Request("comment"))
rs.Update
rs.close
set conn=nothing
response.redirect Request.ServerVariables("Http_referer")
'response.redirect "menuadmin.asp"
End If

'Modify Record
If Action="Mod" Then
MenuID=Int(request("ID"))
sql= "SELECT * from CMDB_Type WHERE type_id="&MenuID
rs.open sql,conn,1,3
rs("type_name") =Trim(Request("name"))
rs("type_fatherID") =CInt(Request("fatherID"))
rs("type_comment") =Trim(Request("comment"))
rs.Update
rs.close
set conn=nothing
response.redirect Request.ServerVariables("Http_referer")
'response.redirect "menuadmin.asp"
End If



'Delete Record
If Action="Del" Then
MenuID=Int(request("ID"))
sql= "delete  FROM CMDB_Type WHERE type_id="&MenuID
conn.execute (sql)
set conn=nothing
'response.redirect Request.ServerVariables("Http_referer")
response.redirect "AssetConfigTypeAdmin.asp"
End If


%>

<!--#include file="Footer.asp" -->
